﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace EasySL.Controls
{
    public delegate void OnConfirm();
    
    public partial class Confirm : UserControl
    {
        private OnConfirm onConfirm;

        public Confirm(string msg, OnConfirm onConfirm)
        {
            InitializeComponent();
            this.msg.Text = msg;
            this.onConfirm = onConfirm;  
            this.confirmPanel.OnClose += new RoutedEventHandler(this.ClosePanel);
            this.mask.MouseLeftButtonDown += new MouseButtonEventHandler(mask_MouseLeftButtonDown);
            this.confirm.Click += new RoutedEventHandler(confirm_Click);
        }

        void confirm_Click(object sender, RoutedEventArgs e)
        {
            this.Visibility = Visibility.Collapsed;
            if (this.onConfirm != null)
                onConfirm();
        }

        public void ClosePanel(object sender, RoutedEventArgs e)
        {
            this.Visibility = Visibility.Collapsed;
        }

        void mask_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.Visibility = Visibility.Collapsed;
        }
    }
}
